"""
继承
"""

# 定义一个父类
class Person:

    def __init__(self,  name, age, gender, address): # 定义共有的属性
        self.name = name
        self.age = age
        self.gender = gender
        self.address = address

    def speak(self):
        print(f'我叫{self.name}，我向大家问好')


# 子类，派生类
class Student(Person):
    def __init__(self,stu_id,name,age,gender,address):
        super().__init__(name,age,gender,address)
        self.stu_id = stu_id # 自定义的属性

    def study(self):
        print(f'我是学生，我爱学习')

# 属性 salary ，方法 teach
class Teacher(Person):
    def __init__(self,name,age,gender,address,salary):
        super().__init__(name,age,gender,address)
        self.salary = salary

    def teach(self):
        print('我是老师，我在教我的学生摊煎饼')

# 属性rank , 方法cut
class Doctor(Person):
    def __init__(self,name,age,gender,address,rank):
        super().__init__(name,age,gender,address)
        self.rank = rank

    def cut(self):
        print('我是医生，我会做手术')


if __name__ == '__main__':
    s = Student(1,'聂茹凤', 22, '女', '北京市海淀区')
    # print(s.stu_id)
    # print(s.name)
    # s.speak()
    # s.study()

    t = Teacher('张纪豪',33,'男','北京市朝阳区',3200)
    print(t.salary) # 访问自己的属性
    print(t.gender) # 访问继承的属性

    t.speak() # 调用继承的方法
    t.teach()  # 调用自己的方法